package com.jsu.clubmanagementsystem.model.vo.user;

import com.jsu.clubmanagementsystem.model.entity.User;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
public class UserVO implements Serializable {
    /**
     * 用户id
     */
    private Long id;

    /**
     * 用户账号
     */
    private String userAccount;

    /**
     * 用户名/姓名
     */
    private String userName;

    /**
     * 用户头像
     */
    private String userAvatar;

    /**
     * 电话号码
     */
    private String phoneNumber;

    /**
     * 专业
     */
    private String major;

    /**
     * 年级: 大一/大二/大三/大四
     */
    private String grade;

    /**
     * 班级
     */
    private String userClass;

    /**
     * 所管理的社团id
     */
    private Long managedClubId;

    /**
     * 用户角色
     */
    private String userRole;

    private static final long serialVersionUID = 1L;

    public static UserVO objToVoAllInfo(User user) {
        UserVO userVO = new UserVO();
        BeanUtils.copyProperties(user, userVO);
        return userVO;
    }

    public static UserVO objToVoLessInfo(User user) {
        if (user == null) {
            return null;
        }
        UserVO userVO = new UserVO();
        Long id = user.getId();
        String userAccount = user.getUserAccount();
        String userName = user.getUserName();
        String userAvatar = user.getUserAvatar();
        Long managedClubId = user.getManagedClubId();
        String userRole = user.getUserRole();

        userVO.setId(id);
        userVO.setUserAccount(userAccount);
        userVO.setUserName(userName);
        userVO.setUserAvatar(userAvatar);
        userVO.setManagedClubId(managedClubId);
        userVO.setUserRole(userRole);
        return userVO;
    }
}
